package com.atguigu.lease.web.admin.controller.apartment;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.module.entity.LeaseTerm;
import com.atguigu.lease.web.admin.service.LeaseTermService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/term")
@Tag(name = "租期管理",description = "leaseTermController")
public class LeaseTermController {
    @Autowired
    private LeaseTermService leaseTermService;

    @GetMapping("list")
    public Result<List<LeaseTerm>> getList(){
        return Result.ok(leaseTermService.list());
    }

    @PostMapping("saveOrUpdate")
    public Result saveOrUpdate(@RequestBody LeaseTerm leaseTerm){
        leaseTermService.saveOrUpdate(leaseTerm);
        return Result.ok();

    }

    @DeleteMapping("delete")
    public Result delete(@RequestParam Long id){
        leaseTermService.removeById(id);
        return Result.ok();
    }
}
